<?php
namespace Home\Controller;

use Common\Controller\UserBaseController;

/**
 * 首页控制器
 */
class NoticeController extends UserBaseController
{
    /**
     * 首页
     */
    public function index()
    {

        // $notice=D('Article')->getOneArticle('52');
        $Notice              = M('Article');
        $map['ac_id']        = 10;
        $map['article_show'] = 1;
        $notice              = $Notice->field('article_content')->where($map)->order('article_sort asc ,article_time desc')->select();

        foreach ($notice as $k => $v) {

            $content[] = $v['article_content'];

        }

        $content1 = implode("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ", $content);

        $content_02 = htmlspecialchars_decode($content1);
        //$content_03 = str_replace("&nbsp;","",$content_02);//将空格替换成空
        $contents = strip_tags($content_02); //函数剥去字符串中的 HTML、XML 以及 PHP 的标签,获取纯文本内容

        echo $contents;exit;
        // ajax_return('水水水水水水水水水水水水水水水水');

    }

    public function all()
    {

        $contidion['ac_id']        = $_GET['ac_id'];
        $contidion['article_show'] = $_GET['article_show'];
        $list                      = M('article')->where($contidion)->order('article_sort asc ,article_time desc')->select();
        // print_r($list);exit;
        $data = array();
        foreach ($list as $k => $v) {
            $content_02 = htmlspecialchars_decode($v['article_content']);
            $content_03 = str_replace("&nbsp;", "", $content_02); //将空格替换成空
            $contents   = strip_tags($content_03); //函数剥去字符串中的 HTML、XML 以及 PHP 的标签,获取纯文本内容

            $data[$k]['agent']   = 1;
            $data[$k]['alert']   = 1;
            $data[$k]['created'] = $v['article_time'];
            $data[$k]['member']  = 1;
            $data[$k]['member1'] = 1;
            $data[$k]['member2'] = 1;
            $data[$k]['text']    = $contents;
            $data[$k]['userid']  = 'dsn-dsn';
        }
        //print_r($data);exit;
        echo json_encode($data);
        exit(0);
    }

}
